//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.kun.portal.webframe.po;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.kun.portal.webframe.util.Loaded;
import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

@Entity
@Table(
        name = "fw_team"
)
@DynamicUpdate(true)
@Cacheable

@NamedEntityGraph(name = "load_userList",
        attributeNodes = {
                @NamedAttributeNode(value="userList", subgraph = "roles"),
                @NamedAttributeNode("roleSet"),
                @NamedAttributeNode("dutyUser")
        })
public class FwTeamPo implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id

    @GeneratedValue(
            generator = "team_id"
    )
    @GenericGenerator(
            name = "team_id",
            strategy = "uuid"
    )
    @Column(
            name = "team_id",
            length = 32,
            nullable = false
    )
    private String teamId;

    @Column(
            name = "team_code",
            length = 100
    )
    private String teamCode;
    @Column(
            name = "team_name",
            length = 200
    )
    private String teamName;
    @Column(
            name = "team_type",
            length = 200
    )
    private String teamType;


    @Column(
            name = "service_time",
            length = 200
    )
    private Integer serviceTime;

    @Column(
            name = "parent_code",
            length = 100
    )
    private String parentCode;
    @Column(
            name = "parent_name",
            length = 100
    )
    private String parentName;
    @Column(
            name = "team_level",
            length = 5
    )
    private String teamLevel;
    @Column(
            name = "team_status",
            length = 5
    )
    private String teamStatus = "1";
    @Column(
            name = "remark",
            length = 1024
    )
    private String remark;
    @Column(
            name = "create_time",
            length = 20
    )
    private String createTime;
    @Column(
            name = "modify_time",
            length = 20
    )
    private String modifyTime;
    @Column(
            name = "creator",
            length = 32
    )
    private String creator;
    @Column(
            name = "area_code",
            length = 32
    )
    private String areaCode;
    @ManyToMany(
            cascade = CascadeType.DETACH,
            fetch = FetchType.LAZY
    )
    @JoinTable(
            name = "fw_team_user",
            joinColumns = {@JoinColumn(
                    name = "team_id",
                    referencedColumnName = "team_id"
            )},
            inverseJoinColumns = {@JoinColumn(
                    name = "user_id",
                    referencedColumnName = "user_id"
            )}
    )

    private Set<FwUserPo> userList;
    @ManyToMany(
            cascade = CascadeType.DETACH,
            fetch = FetchType.LAZY
    )
    @JoinTable(
            name = "fw_team_duty",
            joinColumns = {@JoinColumn(
                    name = "team_id",
                    referencedColumnName = "team_id"
            )},
            inverseJoinColumns = {@JoinColumn(
                    name = "user_id",
                    referencedColumnName = "user_id"
            )}
    )
    @Cache(
            usage = CacheConcurrencyStrategy.READ_WRITE
    )
    private Set<FwUserPo> dutyUser;
    @Column(
            name = "duty_base_num"
    )
    private Integer dutyBaseNum;

    @ManyToMany(
            cascade = {CascadeType.REFRESH},
            fetch = FetchType.LAZY
    )
    @JoinTable(
            name = "fw_team_role",
            joinColumns = {@JoinColumn(
                    name = "team_id",
                    referencedColumnName = "team_id"
            )},
            inverseJoinColumns = {@JoinColumn(
                    name = "role_id",
                    referencedColumnName = "role_id"
            )}
    )
    //@JsonIgnore
    @Cache(
            usage = CacheConcurrencyStrategy.READ_WRITE
    )
    private Set<FwRolePo> roleSet = new HashSet();
    @Transient
    private List<String> moduleList;

    public FwTeamPo() {
    }

    public void setTeamId(String teamId) {
        this.teamId = teamId;
    }

    public String getTeamId() {
        return this.teamId;
    }

    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }

    public String getTeamCode() {
        return this.teamCode;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }

    public String getTeamName() {
        return this.teamName;
    }

    public String getTeamType() {
        return this.teamType;
    }

    public void setTeamType(String teamType) {
        this.teamType = teamType;
    }

    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }

    public String getParentCode() {
        return this.parentCode;
    }

    public void setTeamLevel(String teamLevel) {
        this.teamLevel = teamLevel;
    }

    public String getTeamLevel() {
        return this.teamLevel;
    }

    public void setTeamStatus(String teamStatus) {
        this.teamStatus = teamStatus;
    }

    public String getTeamStatus() {
        return this.teamStatus;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getCreateTime() {
        return this.createTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    public String getModifyTime() {
        return this.modifyTime;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getCreator() {
        return this.creator;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getRemark() {
        return this.remark;
    }

    public String getParentName() {
        return this.parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public Set<FwUserPo> getUserList() {
        return (Set<FwUserPo>) Loaded.loaded(this.userList);
    }

    public void setUserList(Set<FwUserPo> userList) {
        this.userList = userList;
    }

    public void setTeamUserList(List<Object> teamUserList) {
//        if(teamUserList != null) {
//            if(this.userList == null) {
//                this.userList = new ArrayList();
//            }
//
//            Iterator var3 = teamUserList.iterator();
//
//            while(var3.hasNext()) {
//                Object o = var3.next();
//                Map<String, String> map = (Map)o;
//                FwUserPo user = new FwUserPo();
//                user.setUserId((String)map.get("userId"));
//                this.userList.add(user);
//            }
//        }

    }

    public Set<FwRolePo> getRoleSet() {
        return (Set<FwRolePo>) Loaded.loaded(roleSet);
    }

    public void setRoleSet(Set<FwRolePo> roleSet) {
        this.roleSet = roleSet;
    }

    public void addRole(FwRolePo role) {
//        role.setTeamPo(this);
        this.roleSet.add(role);
    }

    public int hashCode() {
        int result = 1;
        result = 31 * result + (this.teamId == null?0:this.teamId.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if(this == obj) {
            return true;
        } else if(obj == null) {
            return false;
        } else if(this.getClass() != obj.getClass()) {
            return false;
        } else {
            FwTeamPo other = (FwTeamPo)obj;
            if(this.teamId == null) {
                if(other.teamId != null) {
                    return false;
                }
            } else if(!this.teamId.equals(other.teamId)) {
                return false;
            }

            return true;
        }
    }

    public List<String> getModuleList() {
        return this.moduleList;
    }

    public void setModuleList(List<String> moduleList) {
        this.moduleList = moduleList;
    }

    public String getAreaCode() {
        return this.areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public Integer getServiceTime() {
        if(serviceTime==null){
            serviceTime=0;
        }
        return serviceTime;
    }

    public void setServiceTime(Integer serviceTime) {
        this.serviceTime = serviceTime;
    }

    public Set<FwUserPo> getDutyUser() {
        return (Set<FwUserPo>) Loaded.loaded(dutyUser);
//        return null;
    }

    public void setDutyUser(Set<FwUserPo> dutyUser) {
        this.dutyUser = dutyUser;
    }

    public Integer getDutyBaseNum() {
        return (dutyBaseNum==null?1:dutyBaseNum);
    }

    public void setDutyBaseNum(Integer dutyBaseNum) {
        this.dutyBaseNum = dutyBaseNum;
    }
}
